package com.udata.client;

import com.google.gwt.activity.shared.Activity;
import com.google.gwt.activity.shared.ActivityMapper;
import com.google.gwt.place.shared.Place;
import com.udata.client.activity.DashboardActivity;
import com.udata.client.activity.DocumentActivity;
import com.udata.client.activity.TiebaExpActivity;
import com.udata.client.activity.UserActivity;
import com.udata.client.activity.UserRegisterActivity;
import com.udata.client.place.DashboardPlace;
import com.udata.client.place.DocumentPlace;
import com.udata.client.place.TiebaExpPlace;
import com.udata.client.place.UserPlace;
import com.udata.client.place.UserRegisterPlace;

public class AppActivityMapper implements ActivityMapper {
  private ClientFactory clientFactory;

  public AppActivityMapper(ClientFactory clientFactory) {
    super();
    this.clientFactory = clientFactory;
  }

  @Override
  public Activity getActivity(Place place) {
    if (place instanceof TiebaExpPlace) {
      return new TiebaExpActivity((TiebaExpPlace) place, clientFactory);
    }
    if (place instanceof UserPlace) {
      return new UserActivity((UserPlace) place, clientFactory);
    }
    if (place instanceof DashboardPlace) {
      return new DashboardActivity((DashboardPlace) place, clientFactory);
    }
    if (place instanceof UserRegisterPlace) {
      return new UserRegisterActivity((UserRegisterPlace) place, clientFactory);
    }
    if (place instanceof DocumentPlace) {
      return new DocumentActivity((DocumentPlace) place, clientFactory);
    }
    return null;
  }
}